
li = [5, 7, 4, 9, 1]

#冒泡排序
for x in range(0, len(li) - 1):
    for i in range(0, len(li) - 1 - x):
        if li[i] > li[i + 1]:
            li[i], li[i + 1] = li[i + 1], li[i]

print(li)